var box6 = echarts.init(document.getElementById("box6"),'macarons');
function resizeChart(){
    box6.resize()
}
window.addEventListener('resize',resizeChart)
$.get('./data/area.json').done(function(data) {
    box6.setOption({
        title: {
            text: '开发人员的地域分布',
            subtext:'Top',

            subtextStyle:{
              color:"#4abcff",
                fontSize:20
            },
            left:0,
            top:20,
            itemGap:45
        },
        tooltip: {
            trigger: 'item',
            formatter: function (params) {
                console.log(params)
                if (params.name) {
                    return params.name + ' : ' + (isNaN(params.value) ? 0 : parseFloat(params.value))+"%";
                }
            }
        },
        visualMap: {//视觉映射组件
            top: '25%',
            left: 'left',
            min: 10,
            max: 50000,
            pieces:[
                {
                    gt:18,
                    lt:19,
                    label:"北京",
                    color:"#fac858"
                },{
                    gt:17,
                    lt:18,
                    label:"广东",
                    color:"#91cc75"
                },{
                    gt:10,
                    lt:11,
                    label:"江苏",
                    color:"#73c0de"
                },{
                    gt:6,
                    lt:7,
                    label:"上海",
                    color:"#dc69aa"
                },{
                    gt:4.7,
                    lt:5,
                    label:"浙江",
                    color:"#b6a2de"
                },{
                    gt:3,
                    lt:4.36,
                    label:"湖北",
                    color:"#d87a80"
                },
                {
                    gt:0,
                    lt:3,
                    label:"其它",
                    color:"#96dee8"
                }
            ],
            textStyle:{
                color:'#333'
            },
            missing:'#dddddd',
            realtime: false,  //拖拽时，是否实时更新
        },
        series: [
            {
                name: '中国地图',
                type: 'map',
                mapType: 'china',
                roam:true,
                itemStyle: {
                    normal: {
                        label: {
                            show: true,
                            textStyle: {
                                color: "black"
                            }
                        },
                    },
                    zoom: 1.5,
                    emphasis: {
                        label: {show: true},
                        areaColor: '#ffb980'
                    }
                },
                top: "20%",
                left:70,
                data: data
            }
        ]
    })
})
box6.on('click',function(params){
    window.open('https://www.baidu.com/s?wd='+encodeURIComponent(params.name));
})